﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AgenciaViajeServices.Dominio;
using AgenciaViajeServices.Persistencia;

namespace AgenciaViajeServices
{
    public class Areas : IAreas
    {
        private AreaDAO areaDAO = null;
        private AreaDAO AreaDAO
        {
            get
            {
                if (areaDAO == null)
                    areaDAO = new AreaDAO();
                return areaDAO;
            }
        }

        public Area CrearArea(string des, string res)
        {
            Area areaACrear = new Area()
            {
                Descripcion = des,
                Responsable = res,
            };
            return AreaDAO.Crear(areaACrear);
        }

        public Area ObtenerArea(int codigo)
        {
            return AreaDAO.Obtener(codigo);
        }

        public Area ModificarArea(int cod, string des, string res)
        {
            Area areaAModificar = new Area()
            {
                Codigo = cod,
                Descripcion = des,
                Responsable = res,
            };
            return AreaDAO.Modificar(areaAModificar);
        }

        public void EliminarArea(int codigo)
        {
            Area areaExistente = AreaDAO.Obtener(codigo);
            AreaDAO.Eliminar(areaExistente);
        }

        public List<Area> ListarAreas()
        {
            return AreaDAO.ListarTodos().ToList();
        }
    }
}
